The MineSweeper Type Provider

:: fsharp, type providers

Being able to play Mine Sweeper inside your IDE via intellisense, that is what you have always wanted right? Well, I’m always willing to lend a hand! With this fantastic new type provider you can pretend you are working when really you are avoiding mines. To get started simply clone and build the provider from here. Reference your new shiny type provider library from a script file and create a type alias and then an instance of it like so:

image

The three parameters you can pass determine the grid width, height and amount of mines.

Navigate to the “Start” property of your instance to begin the game. Intellisense will show a representation of the grid state on the top property marked “# Mine Field” and an additional property for each available move in the format of X:Y

image

To play the game simply navigate to the property that represents the tile you would like to reveal.

image

Unfortunately once again it seems that Microsoft simply didn’t have this kind of thing in mind when they were designing intellisense, and it isn’t very happy about making the text line up nicely. I have tried my best for it to not get too difficult.

Disclaimer: Development managers, I am not responsible for any loss of productivity from your staff that this type provider may cause.

EDIT: Props to Phil Trelford for the original minesweeper code from fssnip, which is largely intact here with a few modifications.